import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'lib-flexible/flexible'

import axios from 'axios'
import VueAxios from 'vue-axios'
import waterfall from 'vue-waterfall2'
Vue.use(VueAxios, axios)


import { 
  Tabbar,
  TabbarItem,
  Button,
  Search,
  Tab,
  Tabs,
  Swipe,
  SwipeItem,
  Icon,
  Loading,
  NoticeBar,
  IndexBar,
  IndexAnchor,
  Cell,
  CellGroup,
  Sidebar,
  SidebarItem,
  NavBar,
  Toast,
  ShareSheet,
  Popup,
  Form,
  Field,
  Notify,
  Image as VanImage,
  Uploader,
  Picker,
  Dialog    
} from 'vant';

Vue
.use(Tabbar)
.use(TabbarItem)
.use(Button)
.use(Search)
.use(Tab)
.use(Tabs)
.use(Swipe)
.use(SwipeItem)
.use(Icon)
.use(Loading)
.use(NoticeBar)
.use(IndexBar)
.use(IndexAnchor)
.use(Cell)
.use(CellGroup)
.use(Sidebar)
.use(SidebarItem)
.use(NavBar)
.use(Toast)
.use(waterfall)
.use(ShareSheet)
.use(Popup)
.use(Form)
.use(Field)
.use(Notify)
.use(VanImage)
.use(Uploader)
.use(Picker)
.use(Dialog)

Vue.config.productionTip = false

axios.defaults.baseURL = 'https://apis.netstart.cn/douguo/'

axios.interceptors.request.use(config=>{

  if(config.method == 'get'){
    config.params = config.params || {}

    if(config.url!='home/events/getlists' && config.url!='recipe/search' && config.url!='recipe/search/suggests'){
      let paramsData = ''
      for(let key in config.params){
        paramsData += `/${config.params[key]}` 
      }
      config.url += `${paramsData}`
    } 
  }

  return config
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
